import Taro from "@tarojs/taro";
import { View, Text } from "@tarojs/components";
import "./note.less";

export default class Note extends Taro.Component {
  constructor() {
    super(...arguments);
  }

  componentWillMount() {}

  // 跳转详情页
  toNoteDetailPage() {
    Taro.navigateTo({
      url: `/pages/note-detail/note-detail?noteId=${this.props.note.id}&from=${
        this.props.from
      }`
    });
  }

  render() {
    return (
      <View className="note-container">
        <View className="note-box">
          <View className="note-item">
            <View
              className="doc-info-summary"
              onTap={this.toNoteDetailPage.bind(this)}
            >
              <Text className="doc-title">{this.props.note.title}</Text>
              {this.props.showDesc ? (
                <View className="doc-container">
                  <View className="description">
                    {this.props.note.description}
                  </View>
                  {this.props.note.cover ? (
                    <View>
                      <Image mode="aspectFit" src={this.props.note.cover} />
                    </View>
                  ) : (
                    ""
                  )}
                </View>
              ) : (
                ""
              )}
              <Text className="meta">{this.props.note.createdAt}</Text>
            </View>
          </View>
        </View>
      </View>
    );
  }
}
